package com.ecfront.test.server;


import junit.framework.TestCase;
import com.ecfront.exception.UserException;
import com.ecfront.service.UserService;
import com.ecfront.test.dao.SpringUtilTest;

public class testUserService extends TestCase{
	private static final UserService userService = (UserService)SpringUtilTest.getBean("userService");
	//增加用户测试
	public void testAddUser(){
		try {
			userService.addUser("ecfront", "free2312030@163.com", "ecfront", "ecfront88", "知道ecfront吗？", "知道");
		} catch (UserException e) {
			e.printStackTrace();
		}
	}
	//判断用户名是否存在测试
	public void testFindByName(){
		System.out.println(userService.findUserByName("admin"));
		System.out.println(userService.findUserByName("root"));
	}
	//判断Email是否存在测试
	public void testFindByEmail(){
		System.out.println(userService.findUserByEmail("admin@ecfront.com"));
		System.out.println(userService.findUserByEmail("root@ecfront.com"));
	}
	//测试登录密码修改
	public void testModifLoginPassword(){
		try {
			userService.modifLoginPassword(7,"asdasd", "12345676");
		} catch (UserException e) {
			e.printStackTrace();
		}
	}
	//测试支付密码修改
	public void testModifPayPassword(){
		try {
			userService.modifPayPassword(7, "jlkjlkjlkj234","09876656");
		} catch (UserException e) {
			e.printStackTrace();
		}
	}
	//测试取回登录密码
	public void testGetLoginPwd(){
		try {
			String str = userService.getLoginPwdByAnswer(1, "阿斯顿爱上的");
			if(str==null){
				System.out.println("取回失败！");
			}else{
				System.out.println(str);
			}
		} catch (UserException e) {
			e.printStackTrace();
		}
	}
	//测试取回支付密码
	public void testGetPayPwd(){
		try {
			String str = userService.getPayPwdByAnswer(1, "阿斯顿爱上的");
			if(str==null){
				System.out.println("取回失败！");
			}else{
				System.out.println(str);
			}
		} catch (UserException e) {
			e.printStackTrace();
		}	
	}
}
